home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1994
/
MacHack 1994.toast
/
MacHack™94
/
Talks & Papers
/
Timothy Knox
/
yerk 3.66
/
Toolbox Classes
/
CtlWind
< prev
next >
Wrap
Text File
|
1994-06-24
|
3KB
|
93 lines
\ 1.3.88 rfl A window that will not scroll. This preserves the fprect
\ used by fwind for scrolling.
\ 11.25.90 rfl added close: feature to nonScrollWind. This means that
\ if selected and the window was from a resource, then
\ the global window position will be saved in the resource,
\ but the resource will not save to disk. Note that this
\ defaults to window's close method.
\ 4.20.91 rfl fixed close: so that if rsrc not found, rect isn't left on stack
\ 10.26.91 rfl eliminated nonscrollwind...now savewind
\ 1.17.91 rfl added getnew to make the wind rsrc non purgeable if saveposition=true
\ 6.22.93 rfl changed ctlhit? to handle sys 7 popup menus
create nopurge popA0 " HNoPurge" asmcall next,
:CLASS rsrcWind <super window
int savePosition
:M SAVEPOSITION: put: savePosition ;M
:M GETNEW: getnew: super get: savePosition IF get: resID getres WIND nopurge THEN ;M
\ if the window was brought up from a resource, then save the last position
\ of the window in the resource, but don't save.
:M CLOSE: get: savePosition
IF set: self 0 l->g unpack \ get global corner
getRect: self put: tempRect
offset: tempRect
get: resID getres WIND -dup \ is there a resource?
IF >r get: tempRect r> >ptr put: rect THEN \ ok, so save the window coordinates
THEN
close: super ;M
;CLASS
\ ctlWind - Window subclass adding controls
\ 12/15/84 cbd Version 1
\ 9/04/86 ghs Fixed draw: -do draw: super first so controls are not erased
\ 12/04/87 rfl note that ' ctlproc is correct
\ 1/03/87 rfl super nonScrollWind
Decimal
\ ( part# ctlHndl -- ) execute action for control
: ctlExec exec: [ get-ctl-obj ] ;
\ procedure to be executed when a control is being tracked.
\ ( ctlHndl int:part -- )
:proc ctlProc word0 swap ctlExec ;proc
' ctlProc value ctp
initprocs
\ Look for control click
: ctlHit? { wind \ part mpoint ^ctl action1 action2 -- bool }
where: fEvent g->l -> mpoint \ save mouse loc
Word0 mpoint wind +base
theCtl +base call FindControl
word0 -> part theCtl @ -> ^ctl \ ctl handle
part inThumb = part inCheckBox = or part inButton = or part 1 = or
IF 'c ctlExec -> action2 \ only exec after release
part 1 = IF -1 ELSE 0 THEN -> action1
ELSE ctp +base -> action1
'c 2drop -> action2
THEN ^ctl
IF word0 ^ctl mpoint action1
call TrackControl word0
^ctl exec> action2 true
ELSE false
THEN ;
\ Note: if your Window is a subclass of CtlWind and has scroll bars,
\ it should set the scroll bars to 255 hiliting on a deactivate event.
\ This can be done via the Disable: method in VScroll.
:CLASS CtlWind <Super rsrcWind
\ draw the window with controls
:M DRAW: draw: super (abs) call DrawControls ;M
\ dispose of window's controls and close the window
:M CLOSE: (abs) call KillControls close: super ;M
\ handle a content click
:M CONTENT: active: self
IF ^base ctlHit? not
IF exec: content THEN
ELSE (abs) call SelectWindow
THEN
;M
;CLASS